import pandas as pd
import matplotlib.pyplot as plt

# 读取数据
data = pd.read_csv('order_train1_new.csv')

# 提取线上和线下订单需求量
online_ord_qty = data[data["sales_chan_name"] == "online"]["ord_qty"]
offline_ord_qty = data[data["sales_chan_name"] == "offline"]["ord_qty"]

# 绘制线上和线下订单需求量直方图

plt.hist(online_ord_qty, bins=100, alpha=0.5, color='blue', label='Online')
plt.hist(offline_ord_qty, bins=100, alpha=0.5, color='orange', label='Offline')
plt.title('Distribution of Sales Channels')
plt.xlabel('Order Demand')
plt.ylabel('Frequency')
plt.xlim(0, 700,50) # 设置x轴范围
plt.legend()
plt.show()


import seaborn as sns

# 设置图形风格
sns.set(style="ticks", palette="pastel")

# 绘制箱线图，分析线上和线下订单需求量的分布情况
sns.boxplot(x="sales_chan_name", y="ord_qty", data=data)

# 显示图形
sns.despine(trim=True)